package com.qianfeng.smartplatform.controller;/*
 *@Description:
 *@author:赵健
 *@Date:zjzzz 2022/9/13 20:08
 */

import com.qianfeng.smartplatform.dto.R;
import com.qianfeng.smartplatform.pojo.SysDevice;
import com.qianfeng.smartplatform.service.DeviceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/devices")
public class DeviceController {
    @Autowired
    private DeviceService deviceService;

    @PostMapping("/device")
    public R addDevice(@RequestBody @Validated SysDevice sysDevice) {
        deviceService.addDevice(sysDevice);
        return R.OK();
    }

    @PostMapping("/command/{deviceId}/{command}")
    public R sendCommand(@PathVariable("deviceId") String deviceId, @PathVariable("command") String command) {
        deviceService.sendCommand(deviceId, command);
        return R.OK();
    }
}
